# -*- coding: utf-8 -*-..,
##############################################################################
#
#    @author: PhongND
#    Copyright (C) 2014 Crea8s (http://www.crea8s.com) All Rights Reserved.
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU Affero General Public License as
#    published by the Free Software Foundation, either version 3 of the
#    License, or (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU Affero General Public License for more details.
#
#    You should have received a copy of the GNU Affero General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################


# -*- coding: UTF-8 -*-
'''
    sale

    :copyright: (c) 2014-2015 crea8s
	:author: by PhongND
    :license: AGPLv3, see LICENSE for more details
'''
from openerp.osv import osv, fields
# from openerp.tools.translate import _ 

#for logging 
import logging
_logger = logging.getLogger(__name__) 


class stock_picking_out(osv.osv):
#     _name = "stock.picking"
    _inherit = 'stock.picking.out' 
#     _table="stock_picking"
    _columns = {
        'crea8s_sw_po_ref': fields.char('PO Ref', size=100),
        'crea8s_sw_terms': fields.many2one('account.payment.term', 'Terms',readonly=False), #states={'draft':[('readonly',False)]},
        'crea8s_sw_terms_relate_so': fields.related('sale_id', 'payment_term', type='many2one', relation='account.payment.term', string='Terms SO', store=True), #, digits=(12,6)
        'crea8s_sw_delivery_address01': fields.many2one('crea8s.sw.sp.delivery.address', 'Delivery Address',readonly=False), #states={'draft':[('readonly',False)]},
        'crea8s_sw_delivery_address02': fields.many2one('crea8s.sw.sp.delivery.address', 'Delivery Address02',readonly=False), #states={'draft':[('readonly',False)]},
        'crea8s_sw_delivery_address03': fields.many2one('crea8s.sw.sp.delivery.address', 'Delivery Address03',readonly=False), #states={'draft':[('readonly',False)]},
        'crea8s_sw_delivery_address04': fields.many2one('crea8s.sw.sp.delivery.address', 'Delivery Address04',readonly=False), #states={'draft':[('readonly',False)]},
        
        'crea8s_sw_shipping_id': fields.related('sale_id', 'partner_shipping_id', type='many2one', relation='res.partner', string='Delivery Address', store=True), #, digits=(12,6)
    }
    
    _defaults = {
        'crea8s_sw_po_ref': '',
    }
 
    # def _get_partner_to_invoice(self, cr, uid, picking, context=None):
        # """ desc...
        # """
		# return True
 
stock_picking_out()

class stock_picking(osv.osv):
    _inherit = 'stock.picking' 
    _columns = {
        'crea8s_sw_po_ref': fields.char('PO Ref', size=100),
        'crea8s_sw_terms': fields.many2one('account.payment.term', 'Terms',readonly=False), #states={'draft':[('readonly',False)]},
        'crea8s_sw_terms_relate_so': fields.related('sale_id', 'payment_term', type='many2one', relation='account.payment.term', string='Terms SO', store=True), #, digits=(12,6)
        'crea8s_sw_delivery_address01': fields.many2one('crea8s.sw.sp.delivery.address', 'Delivery Address',readonly=False), #states={'draft':[('readonly',False)]},
        
        'crea8s_sw_delivery_address02': fields.many2one('crea8s.sw.sp.delivery.address', 'Delivery Address02',readonly=False), #states={'draft':[('readonly',False)]},
        'crea8s_sw_delivery_address03': fields.many2one('crea8s.sw.sp.delivery.address', 'Delivery Address03',readonly=False), #states={'draft':[('readonly',False)]},
        'crea8s_sw_delivery_address04': fields.many2one('crea8s.sw.sp.delivery.address', 'Delivery Address04',readonly=False), #states={'draft':[('readonly',False)]},
        'crea8s_sw_shipping_id': fields.related('sale_id', 'partner_shipping_id', type='many2one', relation='res.partner', string='Delivery Address', store=True), #, digits=(12,6)
    }
    
stock_picking()
